package com.nus;

import java.io.IOException;
import java.util.ArrayList;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
import android.util.Log;

import com.nus.parsers.ParserAPIs;
import com.nus.representations.IvleModuleAnnouncements;

//public class IvleModuleOptionsActivity extends Activity{
//	private ListView lv;
//
//	private String lv_arr[]= new String[3];
//	
//	
//	/** Called when the activity is first created. */
//	@Override
//	public void onCreate(Bundle savedInstanceState) {
//		super.onCreate(savedInstanceState);
//		setContentView(R.layout.ivlemoduletabbedlayout);
//
//		
//				        lv_arr[0]="Announcements"; 
//						lv_arr[1]="Forum"; 
//						lv_arr[2]="Grade Book"; 
//				
//			
//		
//		
//		lv=(ListView)findViewById(R.id.moduleLV);
//		lv.setOnItemClickListener(new OnItemClickListener() {
//			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
//					long arg3) {
////				int option= Integer.parselv.getItemAtPosition(arg2).toString());
////				Log.i("value of option", lv.getItemAtPosition(arg2).toString());//i("value of option is",lv.getItemIdAtPosition(arg2));
//				
////				Log.i("value of option","option"+lv.getItemIdAtPosition(arg2));
////				int option = (int)lv.getItemIdAtPosition(arg2);
//				switch(arg2){
//				case 0: startActivity(new Intent("com.nus.IvleModuleAnnouncementActivity"));
//						break;
//				case 1:startActivity(new Intent("com.nus.IvleForumActivity")); break;
//				case 2 : break;
//				}
//			
//			}
//			
//			
//		});
//
//		lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));
//		
//	}
//
//}

public class IvleModuleOptionsActivity extends TabActivity {
	private ListView lv;
	protected TextView title;
	private String lv_arr[] = new String[3];

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.ivlemoduletabbedlayout);
//		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
//		 title = (TextView) findViewById(R.id.titleheader);
//		 title.setText("WorkSpace Dashboard");
		Resources res = getResources(); // Resource object to get Drawables
		TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); // The
																		// activity
																		// TabHost
		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this,
				IvleModuleAnnouncementActivity.class);

		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = tabHost
				.newTabSpec("Announcements")
				.setIndicator("Announcements",
						res.getDrawable(R.drawable.annous)).setContent(intent);
		tabHost.addTab(spec);

		// Do the same for the other tabs
		intent = new Intent().setClass(this, IvleForumActivity.class);
		spec = tabHost.newTabSpec("Forum")
				.setIndicator("Forum", res.getDrawable(R.drawable.forum))
				.setContent(intent);
		tabHost.addTab(spec);
		intent = new Intent().setClass(this, IvleWorkbinActivity.class);
		spec = tabHost.newTabSpec("Workbin").setIndicator("Workbin",res.getDrawable(R.drawable.workbin1))
				.setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, IvleOtherActivity.class);
		spec = tabHost.newTabSpec("More..")
				.setIndicator("More..", res.getDrawable(R.drawable.other))
				.setContent(intent);
		tabHost.addTab(spec);

		tabHost.setCurrentTab(0);
		for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
			// if (i == 0)
			// tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#FFFFFF"));
			//
			// else
			// tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#7392B5"));
			TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i)
					.findViewById(android.R.id.title);
			tv.setTextColor(Color.WHITE);
		}
	}

}